package com.yanqu.road.entity.activity.evefeast.config;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_s_activity_evefeast_mission")
public class EveFeastMissionConfig extends DataObject {
    @FieldTypeAnnotation(select = true, orderASC = true, isIndex = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "轮id", isIndex = true)
    private int turnId;
    @FieldTypeAnnotation(desc = "关卡")
    private int mission;
    @FieldTypeAnnotation(desc = "轮次")
    private int turn;
    @FieldTypeAnnotation(desc = "拥有回合")
    private int round;
    @FieldTypeAnnotation(desc = "通过条件分")
    private int condition;
    @FieldTypeAnnotation(desc = "本轮物品权重系数")
    private String weightParam;
    @FieldTypeAnnotation(desc = "本轮BUFF权重系数")
    private String buffWeightParam;
    @FieldTypeAnnotation(desc = "每轮提供的免费次数 刷新次数|移除次数")
    private String exItem;

    private List<Integer> weightParams = new ArrayList<>();
    private List<Integer> buffWeightParams = new ArrayList<>();
    /**
     * 0 是刷新次数 1 是移除次数
     */
    private List<Integer> timesList = new ArrayList<>();

    /**
     * 每关的物品权重不一样,加载配置时算出物品对应的权重,放这里
     */
    private Map<Integer, Integer> objectWeightMap = new HashMap<>();

    private Map<Integer, Map<Integer, Integer>> objectWeightByType = new HashMap<>();

    /**
     * 每关的BUFF权重不一样,加载配置时算出BUFF对应的权重,放这里
     */
    private Map<Integer, Integer> buffRandomMap = new HashMap<>();
    private Map<Integer, Map<Integer, Integer>> buffRandomMapByQuality = new HashMap<>();

    public EveFeastMissionConfig(int activityId, int turnId) {
        this.activityId = activityId;
        this.turnId = turnId;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getTurnId() {
        return turnId;
    }

    public void setTurnId(int turnId) {
        this.turnId = turnId;
    }

    public int getMission() {
        return mission;
    }

    public void setMission(int mission) {
        this.mission = mission;
    }

    public int getTurn() {
        return turn;
    }

    public void setTurn(int turn) {
        this.turn = turn;
    }

    public int getRound() {
        return round;
    }

    public void setRound(int round) {
        this.round = round;
    }

    public int getCondition() {
        return condition;
    }

    public void setCondition(int condition) {
        this.condition = condition;
    }

    public String getWeightParam() {
        return weightParam;
    }

    public void setWeightParam(String weightParam) {
        this.weightParam = weightParam;
        if (!StringUtils.isNullOrEmpty(weightParam)) {
            this.setWeightParams(StringUtils.stringToIntegerList(weightParam, "\\|"));
        }
    }

    public String getBuffWeightParam() {
        return buffWeightParam;
    }

    public void setBuffWeightParam(String buffWeightParam) {
        this.buffWeightParam = buffWeightParam;
        if (!StringUtils.isNullOrEmpty(buffWeightParam)) {
            this.setBuffWeightParams(StringUtils.stringToIntegerList(buffWeightParam, "\\|"));
        }
    }

    public String getExItem() {
        return exItem;
    }

    public void setExItem(String exItem) {
        this.exItem = exItem;
        if (!StringUtils.isNullOrEmpty(exItem)) {
            this.timesList = StringUtils.stringToIntegerList(exItem, "\\|");
        }
    }

    public int getRefreshTimes() {
        if (this.timesList.size() > 0) {
            return this.timesList.get(0);
        }
        return 0;
    }

    public int getRemoveTimes() {
        if (this.timesList.size() > 1) {
            return this.timesList.get(1);
        }
        return 0;
    }

    public List<Integer> getWeightParams() {
        return weightParams;
    }

    public void setWeightParams(List<Integer> weightParams) {
        this.weightParams = weightParams;
    }

    public List<Integer> getBuffWeightParams() {
        return buffWeightParams;
    }

    public void setBuffWeightParams(List<Integer> buffWeightParams) {
        this.buffWeightParams = buffWeightParams;
    }

    public int getObjectWeightByQuality(int quality) {
        if (quality < 0 || quality >= this.weightParams.size()) {
            return 0;
        }
        return this.weightParams.get(quality);
    }

    public int getBuffWeightByQuality(int quality) {
        if (quality < 0 || quality >= this.buffWeightParams.size()) {
            return 0;
        }
        return this.buffWeightParams.get(quality);
    }

    public Map<Integer, Integer> getNewObjectWeightMap() {
        return new HashMap<>(objectWeightMap);
    }

    public void setObjectWeightMap(Map<Integer, Integer> objectWeightMap) {
        this.objectWeightMap = objectWeightMap;
    }

    public Map<Integer, Integer> getObjectWeightByType(int Type) {
        return objectWeightByType.get(Type);
    }

    public void setObjectWeightByType(Map<Integer, Map<Integer, Integer>> objectWeightByType) {
        this.objectWeightByType = objectWeightByType;
    }

    public Map<Integer, Integer> getNewBuffRandomMap() {
        return new HashMap<>(buffRandomMap);
    }

    public void setBuffRandomMap(Map<Integer, Integer> buffRandomMap) {
        this.buffRandomMap = buffRandomMap;
    }

    public Map<Integer, Integer> getBuffRandomMapByQuality(int quality) {
        if (!buffRandomMapByQuality.containsKey(quality)) {
            return new HashMap<>();
        }
        return new HashMap<>(buffRandomMapByQuality.get(quality));
    }

    public void setBuffRandomMapByQuality(Map<Integer, Map<Integer, Integer>> buffRandomMapByQuality) {
        this.buffRandomMapByQuality = buffRandomMapByQuality;
    }
}
